package it.gius.processing.util;

import java.awt.event.KeyEvent;

import processing.core.PApplet;

@SuppressWarnings("serial")
public abstract class MyAbstractPApplet extends PApplet {
	
	protected GoStop goStop;
	
	public static final char START_STOP_KEY = 's';
	public static final char ESCAPE_SUB_CHAR = 0;
	
	public void setGoStop(GoStop goStop)
	{
		this.goStop = goStop;
		
	}
	
	/*public void setup()
	{
		if(!goStop.isGo())
			noLoop();
	}*/
	
	@Override
	public void keyPressed() {
		
		if(key == KeyEvent.VK_ESCAPE)
		{
			key = ESCAPE_SUB_CHAR;
		}
		
		if(key == START_STOP_KEY && goStop != null)
		{
			goStop.toggle();
		}
			
	}

}
